import 'package:my_flutter_core/utils/date_time_utils.dart';
import 'package:my_flutter_core/utils/format_utils.dart';

class AppInfo {
  AppInfo({
    this.releaseDate,
    this.appVersion,
    this.changeLog,
    this.apkFilename,
    this.apkUrl,
    this.appStoreUrl,
    this.isMandatory,
  });

  factory AppInfo.fromJson(Map<String, dynamic> json) {
    return AppInfo(
      releaseDate: tryToConvert<DateTime>(
        json['releaseDate'],
        (p) => parseDate(p),
      ),
      appVersion: json['appVersion']?.toString(),
      changeLog: json['changeLog']?.toString(),
      apkFilename: json['apkFilename']?.toString(),
      apkUrl: json['apkUrl']?.toString(),
      appStoreUrl: json['appStoreUrl']?.toString(),
      isMandatory: json['isMandatory'] as bool,
    );
  }

  final DateTime? releaseDate;
  final String? appVersion;
  final String? changeLog;
  final String? apkFilename;
  final String? apkUrl;
  final String? appStoreUrl;
  final bool? isMandatory;
}
